//
//  ShengJingMessaegTableViewCell.m
//  JiuKuGospel
//
//  Created by jiukuyinyue on 15-8-25.
//  Copyright (c) 2015年 JiuKuForApp. All rights reserved.
//

#import "ShengJingMessaegTableViewCell.h"

@implementation ShengJingMessaegTableViewCell

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setMessageStr:(NSString *)messageStr
{
    if (ScreenHeight == 667 || ScreenHeight == 736) {
        [self setup6PUI:messageStr];
    }else
    [self setupUI:messageStr];
}

- (void)setupUI:(NSString *)messageStr
{
    [self.allView removeFromSuperview];
    self.allView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.width, self.height)];
    [self addSubview:_allView];
    
    NSString * newMessageH = [NSString stringWithFormat:@"%@", messageStr];
    
    CGRect labTitleRect = [newMessageH boundingRectWithSize:CGSizeMake(self.width-30-45-5, 400) options:(NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading) attributes:[NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:17.0+self.tempMoreFontSize] forKey:NSFontAttributeName] context:nil];
    
    self.allView.frame = CGRectMake(0, 0, self.width, labTitleRect.size.height+10);

    self.numLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 6, 40, 30)];
    _numLabel.textAlignment = NSTextAlignmentCenter;
    _numLabel.font = [UIFont systemFontOfSize:14.0+self.tempMoreFontSize];
    _numLabel.textColor = [UIColor grayColor];
    [_allView addSubview:_numLabel];
    
    self.messageLabel = [[UILabel alloc] initWithFrame:CGRectMake(_numLabel.right+5, 0, self.width-2*15-_numLabel.right-5, labTitleRect.size.height+10)];
    _messageLabel.textColor = [UIColor blackColor];
    _messageLabel.text = newMessageH;
    _messageLabel.numberOfLines = 0;
    [_allView addSubview:_messageLabel];
}

- (void)setup6PUI:(NSString *)messageStr
{
    [self.allView removeFromSuperview];
    self.allView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.width, self.height)];
    [self addSubview:_allView];
    
    NSString * newMessageH = [NSString stringWithFormat:@"%@", messageStr];
    
    CGRect labTitleRect = [newMessageH boundingRectWithSize:CGSizeMake(self.width-30-54, 1000) options:(NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading) attributes:[NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:21.0+self.tempMoreFontSize] forKey:NSFontAttributeName] context:nil];
    
    self.allView.frame = CGRectMake(0, 0, self.width, labTitleRect.size.height+15);

    self.numLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 6, 50, 30)];
    _numLabel.textAlignment = NSTextAlignmentCenter;
    _numLabel.font = [UIFont systemFontOfSize:18.0+self.tempMoreFontSize];
    _numLabel.textColor = [UIColor grayColor];
    [_allView addSubview:_numLabel];
    
    self.messageLabel = [[UILabel alloc] initWithFrame:CGRectMake(_numLabel.right+5, 0, self.width-2*15-_numLabel.right-5, labTitleRect.size.height+15)];
    _messageLabel.textColor = [UIColor blackColor];
    _messageLabel.text = newMessageH;
    _messageLabel.numberOfLines = 0;
    [_allView addSubview:_messageLabel];

}

- (NSInteger)getCellHeight
{
    NSString * newMessage = [NSString stringWithFormat:@"%@", self.messageStr];
    CGRect labTitleRect = [newMessage boundingRectWithSize:CGSizeMake(self.width-40, 400) options:(NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading) attributes:[NSDictionary dictionaryWithObject:FONT_16 forKey:NSFontAttributeName] context:nil];
    return labTitleRect.size.height+15;
}


@end
